/**
 * @author 雷明浩
 * @date 2025/7/18 16:16
 */
public class Merge {
    // 合并两个有序数组
    // https://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D295
    public void merge(int A[], int m, int B[], int n) {
        int index1 = m-1;
        int index2 = n-1;
        int index = m+n-1;
        while (index1 >= 0 && index2 >= 0) {
            if (A[index1] > B[index2]) {
                A[index] = A[index1--];
            } else {
                A[index] = B[index2--];
            }
            index--;
        }
        while (index1 >= 0) {
            A[index--] = A[index1--];
        }
        while (index2 >= 0) {
            A[index--] = B[index2--];
        }
    }
}